package com.geektime.hello.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class Audience {

    @Pointcut("execution(* com.geektime.hello.base.autowired.*.*(..))")
    public void performance() {
    }

    @Pointcut("execution(* com.geektime.hello.base.autowired.SgtPappers.play(..))")
    public void performance2() {
    }

    @Before("performance()")
    public void takeSeats() {
        System.out.println("Taking seats");
    }

    @Around("performance()")
    public void watchPerformance(ProceedingJoinPoint jp) {
        try {
            System.out.println("Silencing cell phones");
            System.out.println("就坐");
            jp.proceed();
            System.out.println("CLAP CLAP CLAP!");
        } catch (Throwable throwable) {
            System.out.println("退票");
        }
    }
}
